﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ASPMVC_first_app.Models;


namespace ASPMVC_first_app.Controllers
{
    public class UserController : Controller
    {
        // GET: User
        //public ActionResult Index()
        //{
        //    var model = new UserModel() { Id=0, FirstName="Uassya", Age= 10};
        //    return View(model);
        //}

        public List<Customer> CreateUsers()
        {
            List<Customer> userList = new List<Customer>();
            userList.Add(new Customer() { Id = 0, FirstName = "Uassya", LastName = "Pup", Age = 10 });
            userList.Add(new Customer() { Id = 1, FirstName = "Feddya", LastName = "Aza", Age = 15 });
            userList.Add(new Customer() { Id = 2, FirstName = "Kostya", LastName = "Modo", Age = 20 });

            return userList;
        }

        public ActionResult Index()
        {
            List<Customer> userList = CreateUsers();

            return View(userList);
        }

        public ActionResult UserInfo(int id)
        {
            List<Customer> userList = CreateUsers();

            if (id < 0 || id > userList.Count()-1)
            {
                return HttpNotFound();
            }
            else
            {
                return View(userList[id]);
            }
        }

        //public ActionResult Action(int minAge, int maxAge)
        //{
        //    List<UserModel> userList = new List<UserModel>();
        //    userList.Add(new UserModel() { Id = 0, Name = "Uassya", Age = 10 });
        //    userList.Add(new UserModel() { Id = 1, Name = "Feddya", Age = 15 });
        //    userList.Add(new UserModel() { Id = 2, Name = "Kostya", Age = 20 });


        //    //return Content(String.Format("ID= {0}, Age = {1}, Name = {2}", id));
        //    return Content(String.Format("minAge={0}, maxAge= {1}", minAge, maxAge));
        //}
    }
}